package com.applet.mallappletbackstage.service.impl;

import com.applet.mallappletbackstage.entity.WorkType;
import com.applet.mallappletbackstage.entity.vo.WorkTypeVO;
import com.applet.mallappletbackstage.mapper.WorkTypeMapper;
import com.applet.mallappletbackstage.service.WorkTypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2020-07-31
 */
@Service
public class WorkTypeServiceImpl extends ServiceImpl<WorkTypeMapper, WorkType> implements WorkTypeService {

    /***
     * 保存工作种类
     * @param workTypeVO
     * @return
     */
    @Override
    public int saveWorkType(WorkTypeVO workTypeVO) {
        WorkType workType = new WorkType();
        BeanUtils.copyProperties(workTypeVO,workType);
        return baseMapper.insert(workType);
    }

    /***
     * 通过id获取工作类型
     * @param id
     * @return
     */
    @Override
    public WorkType getWorkTypeOne(Integer id) {
        QueryWrapper<WorkType> workTypeQueryWrapper = new QueryWrapper<>();
        workTypeQueryWrapper.eq("id",id);
        WorkType workType = baseMapper.selectOne(workTypeQueryWrapper);
        return workType;
    }
}
